import routerName from '@/config/router';
import { ParameterizedContext } from 'koa';
import Router from 'koa-router';
import fs from 'fs';
import path from 'path';

const router = new Router();

router.prefix(routerName);

router.get('/api-doc', async (ctx: ParameterizedContext) => {
  ctx.set('Content-Type', 'application/json');
  const filePath = path.resolve(__dirname, '../../swagger.json');
  const file = fs.readFileSync(filePath);
  ctx.body = file;
});

export default router;
